<template>
  <div class="platform-wrapper">
    <div class="main-hd">
      <h2>{{$t('m.píngtáiguǎnlǐ')}}</h2>
    </div>
    <!--      {{this.$t('m.rLstate')}}-->

    <div class="main-bd">
      <div class="content-wrap">
        <div>
          <div class="items">
            <div class="label">{{$t('m.pst')}}</div>
            <DatePicker type="daterange" format="yyyy-MM-dd" :options="disDate" @on-change="timeChange" :placeholder="$t('m.pst')" style="width: 200px;margin-right: 10px;"></DatePicker>

          </div>
          <div class="items">
            <div class="label">{{$t('m.platName')}}</div>
            <Select v-model="state" style="width: 200px;" :placeholder="$t('m.platName')">
              <Option :value="''"> {{this.$t('m.allplat')}}</Option>
              <Option :value="1">{{this.$t('m.onlinePlat')}}</Option>
              <Option :value="'0'">{{this.$t('m.offlinePlat')}}</Option>
            </Select>
          </div>
          
        <div style="padding-bottom: 15px; clear: both;">
          <Button class="parameter_button" style="margin-right:30px;" @click="state ='',beginDate ='',endDate=''">{{$t('m.recycle')}}</Button>
          <Button class="parameter_button" type="primary" @click="getPlatformList">{{$t('m.cháxún')}}</Button>
          <Button type="primary" style="float: right;" @click="showDaoliuModal(0,'','','','','','','','','','','')">{{this.$t('m.add')}}</Button>
        </div>
        </div>
        <div class="list" style="margin-top: 10px;">
          <Table ref="listTable" border :columns="listColumns" :data="listData" :loading="listLoading"></Table>

          <div style="margin-top:20px; text-align: right;">
            <Page :total="loan_list_size" :current.sync="page" :page-size-opts="[10, 20, 40, 80, 100]" show-total show-elevator show-sizer @on-change="pageChange" @on-page-size-change="handleSizeChange" style="margin: 15px 0;"></Page>
          </div>

          <Modal v-model="addOrEditModal" :title="$t('m.rLstate')" :footer-hide="true" :mask-closable="false" @on-cancel="handleActionCancel">
            <!-- 平台详情=添加按钮 -->
            <i-form :model="formnew" ref="actionForm" :label-width="90" :rules="actionRules">
              <Form-item :label="$t('m.platName')" prop="platformName">
                <i-input v-model="formnew.platformName" :placeholder="this.$t('m.qǐngshūrùpíngtáimíngchēng')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.orName')" prop="contactName">
                <i-input v-model="formnew.contactName" :placeholder="this.$t('m.qǐngshūrùduìjiērénxìngmíng')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.numPhone')" prop="contactPhone">
                <i-input v-model="formnew.contactPhone" :placeholder="this.$t('m.qǐngshūrùliánxìfāngshì')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.jsOr')" prop="settleType">
                <Select v-model="formnew.settleType" style="width: 100%;">
                  <Option :value="'pv'">pv</Option>
                  <Option :value="'uv'">uv</Option>
                  <Option :value="'ca'">ca</Option>
                  <Option :value="'cpa'">cpa</Option>
                  <Option :value="'cpa'">cpa</Option>
                </Select>
                <!--										<i-input v-model="formnew.settleType" placeholder="请输入结算方式"></i-input>-->
              </Form-item>
              <Form-item :label="$t('m.remark')" prop="coopMode">
                <i-input v-model="formnew.remark" :placeholder="this.$t('m.qǐngshūrùbèizhù')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.price')" prop="price">
                <i-input v-model="formnew.price" :placeholder="this.$t('m.qǐngshūrùjiàgé')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.baCC')">
                <i-input v-model="formnew.username" :placeholder="this.$t('m.qǐngshūrùhòutáizhànghào')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.backPassw')">
                <i-input type="password" v-model="formItem.password" :placeholder="this.$t('m.qǐngshūrùhòutáimìmǎ')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.daoliuPages')">
                <i-input v-model="formnew.linkUrl" :placeholder="this.$t('m.qǐngshūrùdǎoliúyèUrl')"></i-input>
              </Form-item>
              <Form-item :label="$t('m.zcBlack')" prop="rejectRegister">
                <RadioGroup v-model="formnew.rejectRegister">
                  <Radio :label="1">{{this.$t('m.yes')}}</Radio>
                  <Radio :label="0">{{this.$t('m.no')}}</Radio>
                </RadioGroup>
              </Form-item>
              <Form-item :label="$t('m.status')" prop="state">
                <RadioGroup v-model="formnew.status">
                  <Radio :label="1">{{this.$t('m.sLine')}}</Radio>
                  <Radio :label="0">{{this.$t('m.xLine')}}</Radio>
                </RadioGroup>
              </Form-item>
              <Form-item>
                <Button type="primary" @click="updateDaoliuPlatform()">{{this.$t('m.submit')}}</Button>
              </Form-item>
            </i-form>
          </Modal>

          <Modal v-model="identityInfo.identityInfoModal" title="第三方引流平台详情" width="1000">
            <div class="threePlat">
              <!-- <p><span>名称:</span>{{Response}}</p> -->
              <p><span>{{$t('m.channelName')}}:</span>{{identityInfo.infoList.platformName}}</p>
              <p><span>id:</span>{{identityInfo.infoList.id}}</p>
              <p><span>平台链接:</span>{{identityInfo.infoList.linkUrl}}</p>
              <p><span>{{$t('m.orName')}}:</span>{{identityInfo.infoList.contactName}}</p>
              <p><span>{{$t('m.numPhone')}}:</span>{{identityInfo.infoList.contactPhone}}</p>
              <p><span>合作模式:</span>{{identityInfo.infoList.coopMode}}</p>
              <p><span>{{$t('m.price')}}:</span>{{identityInfo.infoList.price}}</p>
              <Row :gutter="10">
                <Col span="5" class="card bg1">
                <h5>点击量</h5>
                <h2>{{identityInfo.infoList.clickCount}}</h2>
                <h5>本月累计:{{identityInfo.monthList.clickCount}}</h5>
                </Col>
                <Col span="5" class="card bg2">
                <h5>注册量</h5>
                <h2>{{identityInfo.infoList.registerCount}}</h2>
                <h5>本月累计:{{identityInfo.monthList.registerCount}}</h5>
                </Col>
                <Col span="5" class="card bg3">
                <h5>提交认证量</h5>
                <h2>{{identityInfo.infoList.applyCount}}</h2>
                <h5>本月累计:{{identityInfo.monthList.applyCount}}</h5>
                </Col>
                <Col span="5" class="card bg4">
                <h5>认证成功量</h5>
                <h2>{{identityInfo.infoList.applySuccessCount}}</h2>
                <h5>本月累计:{{identityInfo.monthList.applySuccessCount}}</h5>
                </Col>
                <Col span="4" class="card bg5">
                <h5>下单成功人数</h5>
                <h2>{{identityInfo.infoList.orderCount}}</h2>
                <h5>本月累计:{{identityInfo.monthList.orderCount}}</h5>
                </Col>
              </Row>

              <Row :gutter="10">
                <Col span="5" class="card bg6">
                <h5>注册-认证转化率</h5>
                <h2>{{identityInfo.infoList.applyRate}}%</h2>
                <h5>本月累计:{{identityInfo.monthList.applyRate}}%</h5>
                </Col>
                <Col span="5" class="card bg6">
                <h5>认证-通过转化率</h5>
                <h2>{{identityInfo.infoList.applySuccessRate}}%</h2>
                <h5>本月累计:{{identityInfo.monthList.applySuccessRate}}%</h5>
                </Col>
                <Col span="5" class="card bg6">
                <h5>通过-下单转化率</h5>
                <h2>{{identityInfo.infoList.orderRate}}%</h2>
                <h5>本月累计:{{identityInfo.monthList.orderRate}}%</h5>
                </Col>
                <Col span="9" class="card bg7">
                <h5>下单总金额</h5>
                <h2>{{identityInfo.infoList.orderMoney}}</h2>
                <h5>本月累计:{{identityInfo.monthList.orderMoney}}</h5>
                </Col>
              </Row>
            </div>
          </Modal>
          <!-- 商户列表 end -->
        </div>
      </div>
    </div>

    <Modal v-model="remarkModal" :title="$t('m.remarkDetail')" footer-hide @on-cancel="handleRemarkCancel">
      <div class="remark-body">
        <template v-if="remarkForm">
          <h3 class="remark-head">{{this.$t('m.remarkCo')}}</h3>
          <p class="remark-txt">{{ remark }}</p>
        </template>
        <Form ref="remarkForm" :model="remarkForm" :rules="remarkRules">
          <FormItem label="请在下面输入你需要备注的内容：" prop="remark">
            <Input type="textarea" :autosize="{minRows: 5}" v-model="remarkForm.remark" />
          </FormItem>
          <FormItem>
            <Button type="primary" @click="handleAddRemark">{{this.$t('m.addRemark')}}</Button>
          </FormItem>
        </Form>
      </div>
    </Modal>

    <!--		<Modal-->
    <!--			v-model="riskVisible"-->
    <!--			title="风控模型配置"-->
    <!--			:mask-closable="false"-->
    <!--			@on-cancel="handleRiskCancel"-->
    <!--			footer-hide>-->
    <!--			<Form-->
    <!--				ref="riskForm"-->
    <!--				:model="riskForm"-->
    <!--				:rules="riskRules"-->
    <!--				:label-width="80">-->
    <!--				<FormItem label="风控模型" prop="rmNo">-->
    <!--					<Select v-model="riskForm.rmNo" placeholder="请选择风控模型">-->
    <!--						<Option-->
    <!--							:value="item.rmNo"-->
    <!--							v-for="(item, index) in riskModelList"-->
    <!--							:key="index"-->
    <!--						>{{ item.name }}</Option>-->
    <!--					</Select>-->
    <!--				</FormItem>-->
    <!--				<FormItem style="margin-top: 48px;">-->
    <!--					<Button type="primary" @click="handleRiskSubmit">提交</Button>-->
    <!--					<Button type="error" @click="handleRiskDefault" style="margin-left: 5px;" v-show="defaultRmNo">恢复默认</Button>-->
    <!--				</FormItem>-->
    <!--			</Form>-->
    <!--		</Modal>-->
  </div>
</template>

<script>
const COMPONENT_NAME = 'platform-manage';
import '@/static/style.css';
import '@/static/common.scss';
import mixins from '@/libs/mixins';
import Delete from '@/components/delete';
import ClipboardJS from 'clipboard';
import { dateFormat } from '@/static/tools';
import { deepCopy } from '@/libs/util';

export default {
  name: COMPONENT_NAME,
  mixins: [mixins],
  components: {
    Delete
  },
  data () {
    return {
      // listLoading: true,
      listData: [],
      listColumns: [
        { title: this.$t('m.chaID'), key: 'id', align: 'center', width: 60 },
        { title: this.$t('m.platName'), key: 'platformName', align: 'center' },
        { title: this.$t('m.belongCust'), key: 'contactName', align: 'center' },
        {
          title: this.$t('m.onlineDate'),
          align: 'center',
          render: (h, params) => {
            const { timeOnline } = params.row;
            return h('div', timeOnline);
          }
        },
        // {
        // 	title: '生成链接',
        // 	align: 'center',
        // 	render: (h, params) => {
        // 		const { link } = params.row;
        // 		return h('div', {
        // 			style: {
        // 				marginTop: '2px',
        // 				marginBottom: '2px',
        // 				textAlign: 'left'
        // 			}
        // 		}, link)
        // 	}
        // },
        { title: this.$t('m.clickNum'), key: 'clickCount', align: 'center' },
        { title: 'UV', key: 'settleType', align: 'center' },
        // { title: '注册量', key: 'registerCount', align: 'center' },
        // { title: '提交认证量', key: 'applyCount', align: 'center' },
        // { title: '认证成功量', key: 'applySuccessCount', align: 'center' },
        // { title: '下单人数', key: 'orderCount', align: 'center' },
        // { title: '下单总金额', key: 'orderMoney', align: 'center' },
        // { title: '风控模型', key: 'rmName', align: 'center' },
        {
          title: this.$t('m.black'),
          align: 'center',
          render: (h, params) => {
            const { rejectRegister } = params.row;
            return h('span', rejectRegister == 0 ? '否' : '是')
          }
        },
        {
          title: this.$t('m.autoRM'),
          align: 'center',
          render: (h, params) => {
            let value = params.row.autoSubmitLoanApply;
            return h('span', value == -1 ? '不指定' : value == 0 ? '否' : '是')
          }
        },
        {
          title: this.$t('m.status'),
          align: 'center',
          render: (h, params) => {
            let value = params.row.status;
            return h('span', value == 0 ? this.$t('m.offlinePlat') : this.$t('m.onlinePlat'))
          }
        },
        {
          title: this.$t('m.product'),//产品
          align: 'center',
          render: (h, params) => {
            return h('span', this.productFormat(params.row.loanProductNo));
          }
        },
        {
          title: this.$t('m.lastLandTime'),// '最后登录时间',
          align: 'center',
          render: (h, params) => {
            const { timeOffline } = params.row;
            return h('div', timeOffline);
          }
        },
        {
          title: this.$t('m.operate'),// '操作',
          width: 110,
          classNmae: 'cloumn-space',
          render: (h, params) => {
            const { platformId, id, rmNo, link, username, password, platformName, contactName, contactPhone, settleType, price, linkUrl, status, rejectRegister, remark } = params.row;
            let btn = `btn${id}`;

            return h('div', {
              style: { textAlign: 'left' }
            }, [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small',
                  disabled: platformId === 0
                },
                style: {
                  marginTop: '5px',
                  marginRight: '5px',
                  marginBottom: '5px'
                },
                on: {
                  click: () => {
                    this.showDaoliuModal(1, id, username, password, platformName, contactName, contactPhone, settleType, price, linkUrl, status, rejectRegister, remark);
                  }
                }
              }, this.$t('m.edit')),//编辑
              h('Button', {
                props: {
                  type: 'success',
                  size: 'small',
                  disabled: platformId === 0
                },
                style: {
                  marginTop: '5px',
                  marginRight: '5px',
                  marginBottom: '5px'
                },
                on: {
                  click: () => {
                    this.getPlatformDetail(id);
                  }
                }
              }, this.$t('m.detail')),//'详情'
              h('Button', {
                props: {
                  type: 'info',
                  size: 'small'
                },
                style: {
                  marginTop: '5px',
                  marginRight: '5px',
                  marginBottom: '5px'
                },
                on: {
                  click: () => {
                    this.handleRemark(id, remark);
                  }
                }
              }, this.$t('m.remark')),//'备注'
              // h('Button', {
              // 	props: {
              // 		type: 'warning',
              // 		size: 'small'
              // 	},
              // 	style: {
              // 		marginTop: '5PX',
              // 		marginBottom: '5px'
              // 	},
              // 	on: {
              // 		click: () => {
              // 			this.handleRiskModel(platformId, rmNo);
              // 		}
              // 	}
              // },this.$t('m.fengkongMo') ),//'风控'
              h('Poptip', {
                props: {
                  confirm: true,
                  title: this.$t('m.sdList'),//'你确定要删除此列吗？',
                  placement: 'left',
                  transfer: true
                },
                on: {
                  'on-ok': () => {
                    this.handleDelete(id);
                  }
                }
              }, [
                h('Button', {
                  style: {
                    marginTop: '5px',
                    marginRight: '5px',
                    marginBottom: '5px'
                  },
                  props: {
                    type: 'error',
                    size: 'small',
                    disabled: platformId === 0
                  }
                }, this.$t('m.delete'))//删除
              ]),
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                attrs: {
                  'data-clipboard-text': linkUrl
                },
                style: {
                  marginTop: '5px',
                  marginBottom: '5px'
                },
                class: ['btn-link', btn],
                on: {
                  click: (e) => {
                    let clipboard = new ClipboardJS('.btn-link');
                    clipboard.on('success', (e) => {
                      this.$Message.success(this.$t('m.ctrV'));
                      clipboard.destroy();
                    });

                    clipboard.on('error', (e) => {
                      this.$Message.error('复制链接失败');
                    });
                  }
                }
              }, this.$t('m.linkurl')),//'链接'
            ]);
          }
        }
      ],
      // 开放权限
      columns1: [
        {
          title: '平台id',
          key: 'id'
        },
        {
          title: '平台名称',
          key: 'contactName'
        },
        {
          title: '点击量',
          key: 'clickCountLimit',
          render: (h, col) => {
            var bool = col.row.clickCountLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.clickCountLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '注册量',
          key: 'registerCountLimit',
          render: (h, col) => {
            var bool = col.row.registerCountLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.registerCountLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '提交认证量',
          key: 'applyCountLimit',
          render: (h, col) => {
            var bool = col.row.applyCountLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.applyCountLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '认证成功量',
          key: 'applySuccessCountLimit',
          render: (h, col) => {
            var bool = col.row.applySuccessCountLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.applySuccessCountLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '总下单人数',
          key: 'orderCountLimit',
          render: (h, col) => {
            var bool = col.row.orderCountLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.orderCountLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '总下单金额',
          key: 'orderMoneyLimit',
          render: (h, col) => {
            var bool = col.row.orderMoneyLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.orderMoneyLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '注册-认证转化率',
          key: 'applyRateLimit',
          render: (h, col) => {
            var bool = col.row.applyRateLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.applyRateLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '认证-通过转化率',
          key: 'applySuccessRateLimit',
          render: (h, col) => {
            var bool = col.row.applySuccessRateLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.applySuccessRateLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        },
        {
          title: '通过-下单转化率',
          key: 'orderRateLimit',
          render: (h, col) => {
            var bool = col.row.orderRateLimit == 1 ? true : false;
            return h('checkbox', {
              props: {
                value: bool
              },
              on: {
                'on-change': (event) => {
                  col.row.orderRateLimit = event == true ? 1 : 0;
                  this.updatePlatformLimit(col.row);
                }
              }
            });
          }
        }
      ],
      data1: [],//开发权限的数据data1
      formItems: {
        // id: '1',
        platformName: '',
        linkUrl: '',



        contactName: '',
        contactPhone: '',
        settleType: '',
        coopMode: '',
        price: '',
        state: 1,
        // account: '',
        // password: '',
        // link: '',
        id: 1,
        timeOnline: '',
        timeOnlineEnd: 'YYYY-MM-dd',
        pageSize: 1,
        pageNumber: 1,
        isDelete: 1,



        registerDiscountRateNew: '',
        rejectRegister: 0, // 是否拒绝注册
        autoSubmitLoanApply: -1, // 是否自动提交打款申请
        loanProductNo: 'all' // 设置产品




      },


      formItem: {},


      identityInfo: {

        identityInfoModal: false,
        infoList: [],
        monthList: {}
      },
      id: '',

      beginDate: '',
      endDate: '',
      state: '',
      upDown: 0,
      addOrEditModal: false,
      showModalState: '',
      platFormIsShow: false,
      editList: [],
      type: 1,
      loan_list_size: 1,
      loan_list_page: 1,
      idDelete: 1,
      loading: true,
      disDate: {
        disabledDate (date) {
          return date && date.valueOf() > Date.now();
        }
      },
      pageNumber: 1,
      pageSize: 10,
      remarkModal: false,
      remarkForm: {
        remark: ''
      },
      remarkRules: {
        remark: [
          { required: true, message: this.$t('m.pleaseiR'), trigger: 'blur' }
        ]
      },
      platformId: '',
      id: 1,
      remark: '',
      actionRules: {
        platformName: [
          { required: true, message: this.$t('m.qǐngshūrùpíngtáimíngchēng'), trigger: 'blur' }//this.$t('m.platName')
        ],
        contactName: [
          { required: true, message: this.$t('m.qǐngshūrùduìjiērénxìngmíng'), trigger: 'blur' }
        ],
        contactPhone: [
          { required: true, message: this.$t('m.qǐngshūrùliánxìfāngshì'), trigger: 'blur' }
        ],
        settleType: [
          { required: true, message: this.$t('m.qǐngshūrùjiésuànfāngshì'), trigger: 'blur' }
        ],
        price: [
          { required: true, message: this.$t('m.qǐngshūrùjiàgé'), trigger: 'blur' }
        ],
        // coopMode: [
        // 	{ required: true, message: '请输入合作模式', trigger: 'blur' }
        // ],
        state: [
          { required: true, type: 'number', message: this.$t('m.qǐngxuǎnzézhuàngtài'), trigger: 'change' }
        ],
        rejectRegister: [
          { required: true, type: 'number', message: this.$t('m.qǐngxuǎnzézhùcèhēimíngdān'), trigger: 'change' }
        ],
        autoSubmitLoanApply: [
          { required: true, type: 'number', message: this.$t('m.qǐngxuǎnzézìdòngfàngkuǎn'), trigger: 'change' }
        ]
      },
      riskVisible: false,
      riskType: '',
      riskForm: {
        rmNo: ''
      },
      riskRules: {
        rmNo: [
          { required: true, type: 'string', message: '请选择风控模型', trigger: 'change' }
        ]
      },
      riskModelList: [],
      defaultRmNo: '',
      loanProductNoList: [],

      statusone: 0,
      id: 1,
      testtt: false,
      formnew: {
        username: '',
        password: '',
        platformName: '',
        contactName: '',
        contactPhone: '',
        settleType: '',
        price: 0,
        linkUrl: '',
        status: 0,
        rejectRegister: 0,
        remark: '',


      }
    }
  },
  created () {
    this.formItem = deepCopy(this.formItems);
    this.getLoanProductsList();
    this.getRiskModelList();
    this.getPlatformLimit();
    this.getPlatformList();
  },
  methods: {


    getPlatformList () {   //表格接口
      let param = {}, query = '';
      // 			param.state = this.state;

      param.timeOnlineStart = this.beginDate;
      param.timeOnlineEnd = this.endDate;
      param.status = this.state
      param.pageSize = this.pageSize
      param.pageNumber = this.pageNumber

      var id = this.id
      var status = this.status
      var username = this.username
      var platformName = this.platformName
      var contactName = this.contactName
      var settleType = this.settleType
      var price = this.price
      var timeOnline = this.timeOnline
      var timeOffline = this.timeOffline
      var rejectRegister = this.rejectRegister
      // this.listLoading = true;

      Object.keys(param).forEach((item, index) => {
        if (param[item]) {
          query += `${index === 0 ? '' : '&'}${item}=${param[item]}`;
        }
      });
      var pageNumber = this.pageNumber
      var pageSize = this.pageSize
      var url = `/api/laocai/traffic/list?${query}`
      this.$http.get(url)
        .then((Response) => {
          this.PlatformList = Response.body.result.list
          if (Response.body.code == 0) {
            this.listData = Response.body.result.list;
            this.loan_list_size = Response.body.result.size;
          }
        });
    },
    updateDaoliuPlatform () { //添加
      let param = { ...this.formnew };
      this.id == '' ? '' : param.id = this.id;
      let port = this.statusone == 0 ? '/add' : '/update';
      this.$http.post('/api/laocai/traffic' + port, param).then((res) => {
        if (res.body.code == 0) {
          this.$Message.success('操作成功');
          this.addOrEditModal = false
          // window.location.reload()
          this.getPlatformList()


        } else {
          this.$Message.warning(res.body.message);
        }

      });







      // 			let _this = this, param = {};
      // 			const { actionForm } = this.$refs;
      // 			const { registerDiscountRateNew } = _this.formItem;
      //
      // 			let regRate = (registerDiscountRateNew == '' || isNaN(registerDiscountRateNew)) ? -2 : registerDiscountRateNew;
      // 			param = {
      // 				username: _this.formItem.account,
      // 				password: _this.formItem.password,
      // 				// id: _this.formItem.id || 0,
      // 				platformName: _this.formItem.platformName,
      // 				contactName: _this.formItem.contactName,
      // 				contactPhone: _this.formItem.contactPhone,
      // 				settleType: _this.formItem.settleType,
      // 				// coopMode: _this.formItem.coopMode,
      // 				price: _this.formItem.price,
      // 				linkUrl: _this.formItem.linkUrl,
      // 				status: _this.formItem.state,
      // 				// registerDiscountRateNew: regRate,
      // 				rejectRegister: _this.formItem.rejectRegister,
      // 				remark:_this.formItem.remark
      // 				// autoSubmitLoanApply: _this.formItem.autoSubmitLoanApply,
      // 				// loanProductNo: _this.formItem.loanProductNo == 'all' ? '' : _this.formItem.loanProductNo
      // 			}
      // // 添加
      // 			actionForm.validate(valid => {
      // 				if (valid) {
      // 					this.$http.post('/api/laocai/traffic/add', param)
      // 					.then(function(res){
      // 						console.log(res)
      // 					}, function(err){
      // 						console.log(err);
      // 					});
      // 				}
      // 			});

    },
    // 编辑功能
    showDaoliuModal (statusone, id, username, password, platformName, contactName, contactPhone, settleType, price, linkUrl, status, rejectRegister, remark) {
      this.addOrEditModal = true;
      this.statusone = statusone,
        this.id = id,
        this.formnew.username = username,
        this.formnew.password = password,
        this.formnew.platformName = platformName,
        this.formnew.contactName = contactName,
        this.formnew.contactPhone = contactPhone,
        this.formnew.settleType = settleType,
        this.formnew.price = price,
        this.formnew.linkUrl = linkUrl,
        this.formnew.status = status,
        this.formnew.rejectRegister = rejectRegister,
        this.formnew.remark = remark







      // var _this = this;
      // this.addOrEditModal = true;
      // this.showModalState = showModalState;
      // this.showModalState == 0 ? this.platFormIsShow = false : this.platFormIsShow = true;
      //
      // if(showModalState == 1) {
      // 	this.$http.post('/api/laocai/traffic/update', {
      // 		id:id
      // 	}).then((Response)=> {
      // 		console.log(Response)
      // 		console.log("Response")
      //
      //   	if (res.data.errcode == 0) {
      // 			let info = res.data.data.info;
      // 			_this.formItem = info;
      // 			if (info.registerDiscountRateNew == -2) {
      // 				_this.formItem.registerDiscountRateNew = `默认（${_this.formItem.defaultRegisterDiscountRate}）`;
      // 			}
      // 			if (info.loanProductNo == '') { _this.formItem.loanProductNo = 'all' };
      //   	}
      //   	}, function(err) {});
      // } else {
      // 	this.formItem = deepCopy(this.formItems);
      // }
    },
    getPlatformDetail (id) { //详情功能

      // var _this = this,param = {}, query='';
      this.identityInfo.identityInfoModal = true;
      // var id=this.id,
      // param.platformName=_this.platformName,
      // param.linkUrl=_this.link,
      // param.contactPhone=_this.contactPhone,
      // param.price=_this.price,
      // param = {
      // id:id,
      // 	platformName:_this.platformName,
      // 	linkUrl:_this.link,
      // 	contactPhone:_this.contactPhone,
      // 	price:_this.price,

      // }


      //      Object.keys(param).forEach((item, index) => {
      //      if(param[item]){
      //      query += `${index === 0 ? '' : '&'}${item}=${param[item]}`;
      //      }
      //       });
      var url = '/api/laocai/traffic/info?id=' + id
      //       this.$http.get(url)

      this.$http.get(url)

        // this.$http.get('/api/laocai/traffic/list?pageNumber=1&pageSize=10')
        // this.$http.get('/api/laocai/traffic/list' + '?' + 'pageNumber' + '=' + pageNumber + '&' +'pageSize' + '=' + pageSize)
        .then((Response) => {
          // id:id

          this.identityInfo.infoList = Response.body.result
          // this.identityInfo.monthList =  Response.body.result.list

          // if (res.data.errcode == 0) {
          //   	_this.identityInfo.infoList = Response.body.result
          //   	_this.identityInfo.monthList = res.data.data.monthData;
          // }
        }, function (err) {
          console.log(err);
        });
    },
    timeChange (e) {
      if (typeof (e) == "undefined") {
        this.beginDate = e[0];
      } else if (typeof (e) == "object") {
        this.beginDate = e[0];
        this.endDate = e[1];
      }
      this.page = 1;
      this.getPlatformList();
    },
    pageChange (e) {
      this.pageNumber = e;
      this.getPlatformList();
    },
    // 每页条数
    handleSizeChange (val) {
      this.pageSize = val;
      this.getPlatformList();
    },
    getPlatformLimit () {//获取引流平台权限
      // var this = this,
      //   param = {};


      var id = this.id;
      var contactName = contactName
      var platformName = this.platformName

      var url = '/api/laocai/traffic/list?id=' + id
      this.$http.get(url)
        .then((Response) => {
          this.data1 = Response.body.result.list;
          if (res.data.errcode == 0) {
            this.data1 = Response.body.result.list;
          }
        }, function (err) {
          console.log(err);
        });
    },
    updatePlatformLimit (row) {    //权限点击后的接口,后端还没写接口信息
      var _this = this, param = row;
      this.$http.get('laocai/traffic/update')
        .then((Response) => {
          //   if (res.data.errcode == 0) {
          //   	console.log(res.data.info);
          // }
        }, function (err) {
          console.log(err);
        });
    },
    handleRemark (id, remark) {
      this.id = id;
      this.remark = remark;
      // this.remarkForm.remark=remark
      this.remarkModal = true;

    },
    // 添加备注按钮
    handleAddRemark (id, remark) {
      const { remarkForm } = this.$refs;
      remarkForm.validate(valid => {
        if (valid) {

          // this.$http.post('/api/laocai/traffic/update?id=1&remark=kk')
          var url = '/api/laocai/traffic/update'
          var remark = this.remarkForm.remark
          var id = this.id
          this.$http.post(url, {
            remark: this.remarkForm.remark,
            id: this.id
          }).then((Response) => {
            id: this.id
            remark: this.remarkForm.remark
            if (Response.body.code == 0) {
              this.$Message.success('添加备注成功');
              this.remarkModal = false
              this.handleResetRemark();
              this.getPlatformList();
            }
          }, error => { });
        }
      });
    },
    // 添加备注 取消按钮
    handleRemarkCancel () {
      this.handleResetRemark();
    },
    // remark 重置
    handleResetRemark () {
      this.id = '';
      this.$refs.remarkForm.resetFields();
      this.remarkModal = false;
    },
    handleActionCancel () {
      this.$refs.actionForm.resetFields();
    },
    // 删除平台功能
    handleDelete (id) {
      // var id = this.platformId
      // var isDelete = this.isDelete
      this.$http.post('/api/laocai/traffic/update', {
        id: id,
        isDelete: 1
      }).then((Response) => {
        if (isDelete == 1) {
          this.$Message.success('删除平台成功');
          this.getPlatformList();
        }
      });
    },
    // 获取风控模型 list
    getRiskModelList () {
      this.$http.get('/helsinki/admin/risk-model')
        .then(({ data: { data, info, errcode } }) => {
          if (errcode == 0) {
            this.riskModelList = data
          }
        });
    },
    // 风控配置按钮
    handleRiskModel (id, rmNo) {
      this.platformId = id;
      if (rmNo) {
        this.riskType = 'update';
        this.defaultRmNo = rmNo;
        this.riskForm.rmNo = rmNo;
      } else {
        this.riskType = 'add';
      }
      this.riskVisible = true;
    },
    // 风控提交按钮
    handleRiskSubmit () {
      const { riskForm } = this.$refs;
      riskForm.validate(valid => {
        if (valid) {
          this.$http.post('/helsinki/admin/platform-risk-model-config/update', {
            platformId: this.platformId,
            rmNo: this.riskForm.rmNo
          }).then(({ data: { data, info, errcode } }) => {
            if (errcode == 0) {
              this.$Message.success('风控模型配置成功');
              riskForm.resetFields();
              this.getPlatformList();
              this.riskVisible = false;
            }
          });
        }
      })
    },
    // 风控 恢复默认
    handleRiskDefault () {
      const { riskForm } = this.$refs;
      this.$http.post('/helsinki/admin/platform-risk-model-config/delete', {
        platformId: this.platformId,
        rmNo: this.defaultRmNo
      }).then(({ data: { data, info, errcode } }) => {
        if (errcode == 0) {
          this.$Message.success('恢复默认成功');
          this.defaultRmNo = '';
          riskForm.resetFields();
          this.getPlatformList();
          this.riskVisible = false;
        }
      });
    },
    // 风控弹窗 取消
    handleRiskCancel () {
      this.defaultRmNo = '';
      this.$refs.riskForm.resetFields();
    },
    // 获取产品列表
    getLoanProductsList () {
      this.$http.post('/helsinki/admin/loan-products')
        .then(({ data: { data, errcode, info } }) => {
          if (errcode === 0) {
            let res = data.data;
            this.loanProductNoList = res.filter(item => {
              return item.loanProductNo != 'all'
            });
          }
        }, error => {
          console.log(error);
        })
    }
  },
  watch: {
    state: function () {
      this.page = 1;
      // this.state = state;
      this.getPlatformList();
    }
  }
}
</script>
<style lang="scss" scoped>
.items {
  display: inline-block;
  margin-bottom: 20px;
  margin-right: 20px;
  width: 200px;
  float: left;

  .label {
    overflow: hidden;
    white-space: inherit;
    text-align: right;
    color: #222;
    font-size: 14px;
    margin-right: 10px;
  }
}
.threePlat {
  font-size: 16px;
}

/*$bg:#aeaeae #00cc99 #6666ff #ff6600  #ff3366;*/
.card {
  text-align: center;
  width: 18%;
  margin: 10px 5px 0;
  padding: 30px 0;
  height: 180px;
  background: #f16543;
  color: #fff;
}
.card h2 {
  font-size: 30px;
  margin-top: 30px;
}
.bg1 {
  background: #aeaeae;
}
.bg2 {
  background: #00cc99;
}
.bg3 {
  background: #6666ff;
}
.bg4 {
  background: #ff6600;
}
.bg5 {
  background: #ff3366;
}
.bg6 {
  background: #333333;
}
.bg7 {
  background: #ff9900;
  width: 37%;
}
.remark-txt {
  margin-top: 5px;
  margin-bottom: 15px;
}
.ivu-tabs {
  margin-top: -25px;
}
.ivu-tabs-nav-scroll {
  display: none !important;
}
.ivu-tabs-bar {
  border-bottom: 0px !important;
}

element.style {
  display: none;
}
</style>
